set hive.exec.dynamic.partition= true;
set hive.exec.dynamic.partition.mode= 'nonstrict';
set hive.exec.max.dynamic.partitions.pernode= 200;
set hive.exec.max.dynamic.partitions=200 ;
INSERT OVERWRITE TABLE jms_dm.dm_agent_flow_direction_dt PARTITION (dt)
select date_format(inputtime,'yyyy-MM-dd 00:00:00') as inputtime
       ,count_type
       ,send_network_code  -- 始发网点code
       ,receiver_network_code  -- 签收网点code
       ,send_regional_id  --始发大区id
       ,send_regional  --始发大区name
       ,send_agent_code  -- 始发代理区code
       ,send_agent  -- 始发代理区name
       ,send_fran_code  -- 始发加盟商code
       ,send_fran  -- 始发加盟商name
       ,send_province_id  -- 始发省份id
       ,send_province  -- 始发省份name
       ,send_city_id  -- 始发城市id
       ,send_city  -- 始发城市name
       ,send_area_id  -- 始发区id
       ,send_area  -- 始发区name
       ,send_distributecode  -- 始发转运中心code
       ,send_distribute  -- 始发转运中心name
       ,send_network  -- 始发网点name
       ,receiver_network  -- 签收网点name
       ,receiver_agent_code  -- 签收代理区code
       ,receiver_agent  -- 签收代理区name
       ,receiver_fran_code  -- 签收加盟商code
       ,receiver_fran  -- 签收加盟商name
       ,receiver_regional_id  -- 签收大区id
       ,receiver_regional  -- 签收大区name
       ,receiver_province_id  -- 签收省份id
       ,receiver_province  -- 签收省份name
       ,receiver_city_id  -- 签收城市id
       ,receiver_city  -- 签收城市name
       ,receiver_distributecode  -- 目的转运中心code
       ,receiver_distribute  -- 目的转运中心name
       ,receiver_area_id  -- 签收区id
       ,receiver_area  -- 签收区name
       ,package_number  -- 正向件数
       ,package_total_weight  -- 正向重量
       ,package_total_volume  -- 正向体积
       ,f_package_number -- 反向件数
       ,f_package_total_weight  -- 反向重量
       ,f_package_total_volume  -- 反向体积
       ,entrepot_code  -- 始发集散code
       ,entrepot_name  -- 始发集散name
       ,dispatch_network_code  -- 目的集散网点code
       ,dispatch_network_name  -- 目的集散点name
	   ,dt
from jms_dm.dm_traffic_flow_network_new_dt
where dt='{{ execution_date | cst_ds }}'
and count_type=5
distribute by 1
;
